import socket, select

host = '0.0.0.0'
port = 8890

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 1024000)
s.bind((host, port))
s.listen(5000)
inputs = [s]

while 1:
    infds, outfds, errfds = select.select(inputs, inputs, [], 5)
    if len(infds) != 0:
        # print 'enter infds'
        for fds in infds:
            if fds is s:
                clientsock, clientaddr = fds.accept()
                inputs.append(clientsock)
                # print 'connect from:', clientaddr
            else:
                # print 'enter data recv'
                data = fds.recv(102400)

                if not data:
                    inputs.remove(fds)
                else:
                    pass
                    # print data

    if len(outfds) != 0:
        # print 'enter outfds'
        for fds in outfds:
            fds.send("python select server from Debian.\n")